// Copyright (c) 2007 Jesse deVore

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files
// (the "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;

namespace RpgSdk
{

  public class Player : GameObject
	{
	  private List<UInt32> characters;
	  private List<UInt32> playerFriends;
	  private List<UInt32> chrFriends;
	  private List<UInt32> chrIgnore;
		private UInt32       permissions;
		private Byte[]       passwordHash;
		private Boolean      disabled;
		
		private Dictionary<UInt32, Int32> flags;
		
		public enum Permission
		{
		  PortSelf = 1,
		  PortOther = 2,
		  CreateItem = 4,
		  MasterWho = 8,
		  BanAccount = 16,
		  ModifyPermissions = 32,
		  Announce = 64
		}
		
		public Player()
		{
		  // Get password hash size rule
		  passwordHash = new Byte[1];
		  flags = new Dictionary<UInt32, Int32>();
		}
		
		public Boolean HasPermission(Permission permission)
		{
		  return (permissions & (uint)permission) == (uint)permission;
		}
		
		public void AddPermission(Permission permission)
		{
		  permissions |= (uint)permission;
		}
		
		public List<UInt32> Characters
		{
		  get 
		  {
		    if (characters == null)
		      characters = new List<UInt32>();
		        
		    return characters; 
		  }
		}
		
		public List<UInt32> PlayerFriends
		{
		  get 
		  {
		    if (playerFriends == null)
		      playerFriends = new List<UInt32>();
		        
		    return playerFriends; 
		  }
		}

		public List<UInt32> ChrFriends
		{
		  get 
		  {
		    if (chrFriends == null)
		      chrFriends = new List<UInt32>();
		        
		    return chrFriends; 
		  }
		}

		public List<UInt32> ChrIgnore
		{
		  get 
		  {
		    if (chrIgnore == null)
		      chrIgnore = new List<UInt32>();
		        
		    return chrIgnore; 
		  }
		}

		public Byte[] PasswordHash
		{
		  get { return passwordHash;  }
		  set { passwordHash = value; }
		}
		
		public Boolean Disabled
		{
		  get { return disabled;  }
		  set { disabled = value; }
		}
		
		public Dictionary<UInt32, Int32> Flags
		{
		  get { return flags; }
		}
		
	}
}
